package com.happy.manage.service.impl;

import java.util.List;
import com.happy.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.happy.manage.mapper.MicropostsMapper;
import com.happy.manage.domain.Microposts;
import com.happy.manage.domain.MicropostsWithUser;
import com.happy.manage.service.IMicropostsService;

/**
 * 微贴子Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-27
 */
@Service
public class MicropostsServiceImpl implements IMicropostsService 
{
    @Autowired
    private MicropostsMapper micropostsMapper;

    /**
     * 查询微贴子
     * 
     * @param postId 微贴子主键
     * @return 微贴子
     */
    @Override
    public Microposts selectMicropostsByPostId(Long postId)
    {
        return micropostsMapper.selectMicropostsByPostId(postId);
    }

    /**
     * 查询微贴子列表
     * 
     * @param microposts 微贴子
     * @return 微贴子
     */
    @Override
    public List<Microposts> selectMicropostsList(Microposts microposts)
    {
        return micropostsMapper.selectMicropostsList(microposts);
    }

    /**
     * 查询微贴子列表（带用户信息）
     * 
     * @param microposts 微贴子
     * @return 微贴子集合（带用户信息）
     */
    @Override
    public List<MicropostsWithUser> selectMicropostsWithUserList(MicropostsWithUser microposts)
    {
        return micropostsMapper.selectMicropostsWithUserList(microposts);
    }

    /**
     * 新增微贴子
     * 
     * @param microposts 微贴子
     * @return 结果
     */
    @Override
    public int insertMicroposts(Microposts microposts)
    {
        microposts.setCreateTime(DateUtils.getNowDate());
        return micropostsMapper.insertMicroposts(microposts);
    }

    /**
     * 修改微贴子
     * 
     * @param microposts 微贴子
     * @return 结果
     */
    @Override
    public int updateMicroposts(Microposts microposts)
    {
        microposts.setUpdateTime(DateUtils.getNowDate());
        return micropostsMapper.updateMicroposts(microposts);
    }

    /**
     * 批量删除微贴子
     * 
     * @param postIds 需要删除的微贴子主键
     * @return 结果
     */
    @Override
    public int deleteMicropostsByPostIds(Long[] postIds)
    {
        return micropostsMapper.deleteMicropostsByPostIds(postIds);
    }

    /**
     * 删除微贴子信息
     * 
     * @param postId 微贴子主键
     * @return 结果
     */
    @Override
    public int deleteMicropostsByPostId(Long postId)
    {
        return micropostsMapper.deleteMicropostsByPostId(postId);
    }
}
